package com.lz.androidlibraries.cor

import android.util.Log
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

/**
 * DESC
 *
 * Created by liuyakui on 2022/1/25.
 */
open class Coroutine {
    var count: Int = 0

    fun main() {
        GlobalScope.launch(Dispatchers.Main) {
            Log.e("coroutine", "thread: " + Thread.currentThread().name)
            getNetImage()
            getNetName()
        }
    }

    private suspend fun getNetImage() {
        withContext(Dispatchers.IO) {
            Log.e("coroutine", "getNetImage thread: " + Thread.currentThread().name)
        }
    }

    private suspend fun getNetName() {
        withContext(Dispatchers.IO) {
            Log.e("coroutine", "getNetName thread: " + Thread.currentThread().name)
        }
    }
}